import User.factory.AdminFactory;
import User.factory.IUserFactory;
import User.factory.NormalFactory;
import User.User;
import User.ProxyUser;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 殇
 * Date: 2025-07-16
 * Time: 22:12
 */
public class LibarySystem {
    public static ProxyUser selectProxyUser(ProxyUser proxyUserAdmin,ProxyUser proxyUserNormal1,ProxyUser proxyUserNormal2){
        System.out.println("请选择角色进行登录:");
        System.out.println("1.管理员\n2.普通用户1(关羽)\n3.普通用户2(张飞)\n4.退出系统");

        ProxyUser currentUser=null;
        Scanner scanner=new Scanner(System.in);
        int choice=scanner.nextInt();
        switch (choice){
            case 1:
                currentUser=proxyUserAdmin;
                break;
            case 2:
                currentUser=proxyUserNormal1;
                break;
            case 3:
                currentUser=proxyUserNormal2;
                break;
            case 4:
                System.exit(0);
                System.out.println("程序已退出！！！");
                break;
            default:
                break;
        }
       return currentUser;
    }
    public static <Uesr> void main(String[] args) {
        IUserFactory adminFactory=new AdminFactory();
        User admin=adminFactory.createrUser("刘备",1);

        IUserFactory normalFactory=new NormalFactory();
        User normal1=normalFactory.createrUser("关羽",2);
        User normal2=normalFactory.createrUser("张飞",3);

        ProxyUser proxyUser1=new ProxyUser(admin);

        ProxyUser proxyUser2=new ProxyUser(normal1);

        ProxyUser proxyUser3=new ProxyUser(normal2);

        ProxyUser proxyUser=selectProxyUser(proxyUser1,proxyUser2,proxyUser3);
        while(true){
            int choice =proxyUser.getRealUser().display();
            proxyUser.handelOperation(choice);
        }


    }
}
